package com.homegoods.discover.presenter;

import com.homegoods.classify.model.Constant;
import com.homegoods.discover.R;
import com.homegoods.discover.model.LogisticsModel;
import com.kedll.library.mvp.AbstractRefreshPresenter;
import com.kedll.library.mvp.RefreshingView;

import java.util.List;
import java.util.Random;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;

/**
 * @author QiQi
 * @description 交易物流消息界面Presenter层
 */
public class LogisticsListPresenter extends AbstractRefreshPresenter<RefreshingView> {
    public LogisticsListPresenter(RefreshingView view) {
        super(view);
        emptyItem.setResId(R.mipmap.discover_no_message);
        emptyItem.setContent("暂无消息");
    }

    @Override
    protected void fetchData(boolean isLoadMore) {
        addSubscription(Observable.range(0, 10)
                .map(integer -> {
                    LogisticsModel model = new LogisticsModel();
                    model.setDate("2018-09-23");
                    model.setImageUrl(Constant.TEST_IMG_URL + new Random().nextInt(1000));
                    model.setTitle("米语 8X全面屏4G智能手机安卓超薄大屏千元游戏电信全网通正品");
                    model.setInfo("订单编号：21873827328732");
                    model.setLogisticsStatus("已签收");
                    return model;
                })
                .toList()
                .subscribe(logisticsItems -> LogisticsListPresenter.this.parserData(isLoadMore, logisticsItems)));

    }
}